//
//  VehicleTVCell.m
//  Logistics
//
//  Created by enzhoukeji on 2018/8/7.
//  Copyright © 2018年 puyue.com. All rights reserved.
//

#import "VehicleTVCell.h"

@implementation VehicleTVCell
/**
 ViewCell
 View *headImge;
  *titleL;
 *licensePlateL;
 *leghtL;
@ *modelsL;
*onlineL;
*positioningL;
*collectionL;
*distanceL;
n *telBut;
*/
-(void)loadViews {
    self.headImge = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"touxiangMN"]];
    self.headImge.backgroundColor = [UIColor redColor];
    self.titleL = [UILabel labelWithSize:[UIFont systemFontOfSize:14] withColor:[UIColor grayColor] withText:@"爱情公寓"];
    self.licensePlateL = [UILabel labelWithSize:[UIFont systemFontOfSize:11] withColor:[UIColor grayColor] withText:@"鲁A 66666"];
    self.leghtL = [UILabel labelWithSize:[UIFont systemFontOfSize:11] withColor:[UIColor grayColor] withText:@"22米"];
    self.modelsL = [UILabel labelWithSize:[UIFont systemFontOfSize:11] withColor:[UIColor grayColor] withText:@"车型"];
    self.onlineL = [UILabel labelWithSize:[UIFont systemFontOfSize:9] withColor:[UIColor grayColor] withText:@"在线时间：2小时前"];
    self.positioningL = [UILabel labelWithSize:[UIFont systemFontOfSize:9] withColor:[UIColor grayColor] withText:@"定位：济南"];
    self.distanceL = [UILabel labelWithSize:[UIFont systemFontOfSize:9] withColor:[UIColor grayColor] withText:@"距离我300米"];

    self.telBut = [UIButton buttonWithTitle:nil withImageName:@"gouwuche" withBGColor:[UIColor grayColor] Withlayer:NO];
    [self.telBut addTarget:self action:@selector(telButtonC:) forControlEvents:UIControlEventTouchUpInside];
    
    self.collectionBut = [UIButton buttonWithTitle:@"收藏" withImageName:nil withBGColor:nil Withlayer:NO];
    [self.collectionBut setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    self.collectionBut.titleLabel.font = [UIFont systemFontOfSize:10];
    [self.collectionBut addTarget:self action:@selector(collectionButtonC:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.headImge];
    [self addSubview:self.titleL];
    [self addSubview:self.licensePlateL];
    [self addSubview:self.leghtL];
    [self addSubview:self.modelsL];
    [self addSubview:self.onlineL];
    [self addSubview:self.positioningL];
    [self addSubview:self.distanceL];
    [self addSubview:self.telBut];
    [self addSubview:self.collectionBut];
    
}
-(void)layoutViews {
    [self.headImge mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(GTFixWidthFlaot(10)));
        make.top.equalTo(@(GTFixHeightFlaot(10)));
        make.bottom.mas_offset(GTFixHeightFlaot(-10));
        make.width.mas_equalTo(self.headImge.mas_height);
    }];
    [self.titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.headImge.mas_right).offset(GTFixWidthFlaot(5));
        make.top.mas_equalTo(GTFixHeightFlaot(10));
        make.width.mas_equalTo(GTFixWidthFlaot(50));
        make.height.mas_equalTo(GTFixHeightFlaot(15));
    }];
    [self.licensePlateL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.headImge.mas_right).offset(GTFixWidthFlaot(5));
        make.top.equalTo(self.titleL.mas_bottom).offset(GTFixHeightFlaot(5));
        make.width.mas_equalTo(GTFixWidthFlaot(50));
        make.height.mas_equalTo(GTFixHeightFlaot(15));
    }];
    [self.leghtL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.licensePlateL.mas_right).offset(GTFixWidthFlaot(10));
        make.top.mas_equalTo(self.titleL.mas_bottom).offset(5);
        make.width.mas_equalTo(GTFixWidthFlaot(20));
        make.height.mas_equalTo(GTFixHeightFlaot(15));
    }];
    [self.modelsL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.leghtL.mas_right).offset(GTFixWidthFlaot(10));
        make.top.mas_equalTo(self.titleL.mas_bottom).offset(5);
        make.width.mas_equalTo(GTFixWidthFlaot(20));
        make.height.mas_equalTo(GTFixHeightFlaot(15));
    }];
    [self.onlineL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.headImge.mas_right).offset(GTFixWidthFlaot(5));
        make.top.mas_equalTo(self.licensePlateL.mas_bottom).offset(5);
        make.width.mas_equalTo(GTFixWidthFlaot(65));
        make.height.mas_equalTo(GTFixHeightFlaot(10));
    }];
    [self.positioningL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.onlineL.mas_right).offset(GTFixWidthFlaot(10));
        make.top.mas_equalTo(self.licensePlateL.mas_bottom).offset(5);
        make.width.mas_equalTo(GTFixWidthFlaot(40));
        make.height.mas_equalTo(GTFixHeightFlaot(10));
    }];
    [self.distanceL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.positioningL.mas_right).offset(GTFixWidthFlaot(10));
        make.top.mas_equalTo(self.licensePlateL.mas_bottom).offset(5);
        make.width.mas_equalTo(GTFixWidthFlaot(45));
        make.height.mas_equalTo(GTFixHeightFlaot(10));
    }];
    [self.telBut mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(GTFixWidthFlaot(-23)));
        make.top.mas_equalTo(GTFixHeightFlaot(10));
        make.height.mas_equalTo(GTFixHeightFlaot(20));
        make.width.mas_equalTo(GTFixHeightFlaot(20));
    }];

    [self.collectionBut mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(GTFixWidthFlaot(-20)));
        make.top.mas_equalTo(self.licensePlateL.mas_bottom).offset(5);
        make.height.mas_equalTo(GTFixHeightFlaot(10));
        make.width.mas_equalTo(GTFixWidthFlaot(30));
    }];
}
-(void)setIndexPath:(NSIndexPath *)indexPath{
    _indexPath = indexPath;
}
-(void)telButtonC:(UIButton *)btn {
    if (self.delegate) {
        [self.delegate vehiclewithIndexPath:self.indexPath withtype:@"1"];
    }
}
-(void)collectionButtonC:(UIButton *)btn {
    if (self.delegate) {
        [self.delegate vehiclewithIndexPath:self.indexPath withtype:@"2"];
    }
}
@end
